home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 216 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  4.7 KB

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.lang.c,comp.std.c
  4. Subject: Re: Integral conversion e.t.c. (was: Re: Hungarian notation)
  5. Date: 29 Jan 1996 09:00:10 -0600
  6. Organization: Usenet Fact Police (Undercover)
  7. Message-ID: <4eindq$eju@solutions.solon.com>
  8. References: <30C40F77.53B5@swsbbs.com> <DLtABq.Fzu@mv.mv.com> <4edqh2$rvl@solutions.solon.com> <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
  9. NNTP-Posting-Host: solutions.solon.com
  10.  
  11. In article <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>,
  12. James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> wrote:
  13. >In article <4edqh2$rvl@solutions.solon.com> seebs@solutions.solon.com
  14. >(Peter Seebach) writes:
  15. >In the particular case which you cite, I do *not* believe that gcc
  16. >will compile the program without a diagnostic if the program is in a
  17. >file called a.c.  More ever, the compiler documentation definitly
  18. >states that only programs in files whose names end in .c will be
  19. >compiled as C.  (A legal restriction, as far as I can see.)
  20.  
  21. That's an interesting question; the standard does not visibly make any
  22. such requirements, but you could argue that gcc is only a conforming compiler
  23. when invoked on a file ending in .c.
  24.  
  25. Yes, it would *have* to give a diagnostic for a Fortran program; nonetheless,
  26. the program is *still* conforming if it is accepted.  I think this is a
  27. botch; the standard should probably distinguish between extensions and
  28. violations.
  29.  
  30. >To tell the truth, I'm not sure what the answer is.  The text
  31. >concerning main is in the chapter describing the environment.  It
  32. >doesn't appear as a semantic restriction or anything.  It simply
  33. >states that on start-up, a function called main will be called, and
  34. >that the implementation must support the following forms.  It doesn't
  35. >seem (to me, at least) to say anything about what other forms it might
  36. >support, or what the implementation must do if given a fully other
  37. >definition of main.
  38.  
  39. I would tend to expect a diagnostic in strict ANSI mode, and would also
  40. expect a diagnostic for including <sys/stat.h> in strict ANSI mode.  Neither
  41. is often forthcoming.
  42.  
  43. gcc warns only on implementations where they consider it a hosted environment;
  44. on most systems, they weasel and claim to be a freestanding implementation.
  45.  
  46. >Normally, I would expect (at the very least) a compiler to generate a
  47. >warning or an error for a main that it did not support.  In fact,
  48. >however, my compiler (gcc) accepts the following definition without
  49. >the slightest complaint, although I'd rather not think about what will
  50. >happen when I access parameter d:
  51.  
  52. >    int main( char a , int b , long c , double d )
  53.  
  54. I think that may actually legitimately require a diagnostic; 5.1.2.2.1 gives
  55. us a constraint (?) of "If they are defined, the parameters to the main
  56. function shall obey the following constraints: ..." and some definitions.
  57.  
  58. I would take this as implying that main *must* conform.  I would like to see
  59. them go from "can be declared" to "shall be declared".
  60.  
  61. Already, though, it is clear than any main other than those provided makes
  62. undefined behavior.
  63.  
  64. >Yes and no.  In comp.std.c, the discussion is exactly about what is
  65. >legal according to the standard.  In comp.lang.c (to which this
  66. >article is also cross-posted), the discussion should generally be a
  67. >bit more open.
  68.  
  69. It's debated.  Generally, questions about features of specific compilers or
  70. OS's are off-topic, even when they relate to conforming programs.  Only
  71. strictly conforming programs (or attempts at such, when people are asking
  72. questions) are going to be usable and testable by the whole readership.
  73. (I doubt you can find a single extension that works on *all* machines
  74. we use.)
  75.  
  76. >Thus, for example, in comp.std.c, a program with a variable named far
  77. >is illegal, and that is it.  In comp.lang.c (and I hope in its
  78. >moderated variant), I would hope that someone would point out that,
  79. >legal or not, it's going to get you into trouble.
  80.  
  81. (I assume you meant "...is legal, ...")
  82.  
  83. I generally allow some discussion of system arcana in clcm, but try to
  84. keep it constrained to question s of portability.
  85.  
  86. It appears that the DOS world has started using __far, so I stopped worrying.
  87. I declare variables with names like "near" or "far", and if a compiler can't
  88. take it' the compiler is broken.
  89.  
  90. I have actually had the "good code, no computer to run it on" problem from
  91. this attitude, but hey, it's a hobby.
  92.  
  93. For production code, I cheerfully assume POSIX or other standards.
  94. (And, of course, *document* those assumptions.)
  95.  
  96. -s
  97. -- 
  98. Peter Seebach - seebs@solon.com - Copyright 1995 Peter Seebach.
  99. C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
  100. Using trn?  Weird new newsgroup problem?  I know the fix!  Email me!
  101. The *other* C FAQ - ftp taniemarie.solon.com /pub/c/afq - Not A Flying Toy
  102.